package com.wangsd.web.face.service;

import com.alipay.api.AlipayApiException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.wangsd.web.face.entity.Deposit;
import com.wangsd.web.face.entity.Merchant;
import com.wangsd.web.face.entity.ReceiveRecord;
import com.wangsd.web.face.entity.TOrder;
import com.wangsd.web.miniapp.entity.WxPay;
import com.wangsd.web.sys.entity.SysUser;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author generator
 * @since 2019-09-23
 */
public interface TOrderService extends IService<TOrder> {

    void updateOrderByOutTradeNo(TOrder order);

    //微信原生人脸支付订单
    TOrder createFacePayOrder(String faceCode, String deviceNo, Integer totalFee, Integer memberFee, String phone, String outTradeNo, Long storeUserId) throws Exception;

    /**
     * 人脸押金支付
     */
    TOrder createFaceDepositPayOrder(HttpServletRequest request, String faceCode, String deviceNo, String outTradeNo, Integer consumeFee,
                                     Integer depositFee, Long storeUserId, String subOpenId) throws Exception;

    /**
     * 人脸押金支付
     */
    Deposit returndeposit(HttpServletRequest request, String outTradeNo, String deviceNo, Integer consumeFee, Long storeUserId) throws Exception;

    void doPaymentQueryAndPayment();

    IPage<TOrder> selectList(Integer pageNum, Integer pageSize, TOrder params, String code);

    List<TOrder> selectList(TOrder params, String code);

    List<ReceiveRecord> selectPaymentByOrderId(Long id);

    //扫码后创建微信支付宝订单
    TOrder createScanPayOrder(String deviceNo, Integer totalFee, Integer memberFee, String phone, String outTradeNo, String openid, Integer payType, Long storeUserId);

    //根据商户分账单号查询订单
    TOrder selectByOutOrderNo(String outOrderNo);

    //根据商户订单号查询订单
    TOrder selectByOutTradeNo(String outTradeNo);

    Map selectListStatistics(TOrder params, String code);

    /**
     * 微信小程序查询消费列表数据
     */
    IPage<TOrder> selectMiniList(Integer pageNum, Integer pageSize, WxPay params);

    //会员余额支付
    TOrder payByBalance(String deviceNo, Long totalFee, Long memberFee, Long id, String outTradeNo, Long id1) throws Exception;

    //创建通用通人脸支付订单
    TOrder createTytPayOrder(String faceCode, String deviceNo, Integer totalFee, Integer memberFee, String phone, String outTradeNo, Long id) throws Exception;

    //创建通用通扫码预支付订单
    String createTytScanPayOrder(String deviceNo, String outTradeNo, Integer totalFee, Integer memberFee, String phone, Long userId) throws Exception;

    /**
     * 获取用户结算信息
     */
    Object getCloseAccount(String deviceNo, SysUser sysUser);

    TOrder selectLastByUserIdAndDeviceNo(Long id, String deviceNo);

    /*微信退款*/
    boolean refund(TOrder tOrder, Merchant merchant, SysUser user) throws WxPayException;

    /*微信退款结果查询*/
    boolean refundQuery(TOrder tOrder, Merchant merchant) throws WxPayException;

    /*支付宝退款*/
    boolean aliRefund(TOrder tOrder, Merchant merchant, SysUser user) throws AlipayApiException;

    IPage<TOrder> selectListByDeviceNoAndTime(Integer pageNum, Integer pageSize, String deviceNo, String beginTime, String outTradeNo) throws Exception;

    Object selectListByDeviceNoAndTimeAll(String deviceNo, String beginTime) throws Exception;

    Object getCloseAccountPrint(String deviceNo, String beginTime, SysUser user) throws Exception;

    boolean tytRefund(TOrder tOrder, Merchant merchant, SysUser user) throws Exception;

    boolean memberRefund(TOrder tOrder, Merchant merchant, SysUser user);

    //查询商户统计信息
    Map apiStatisticsByMerchant(Long merchandId, String queryTime, Integer quertType, Integer orderType);

    //查询商户统计，根据门店分组统计
    IPage<Map> apiStatisticsListByMerchant(Integer pageNum, Integer pageSize, Long merchandId, String queryTime, Integer quertType, Integer orderType);

    //查询门店统计信息
    Map apiStatisticsByStore(Long storeId, Long storeUserId, String queryTime, Integer quertType, Integer orderType);

    //查询门店统计，根据店员分组统计
    IPage<Map> apiStatisticsListByStore(Long storeId, Long storeUserId, Integer pageNum, Integer pageSize, String queryTime, Integer quertType, Integer orderType);

    /*支付宝条码支付*/
    TOrder aliBarCodePay(String authCode, String deviceNo, Integer totalFee, Integer memberFee, String outTradeNo, Long userId) throws AlipayApiException, Exception;

    //查询店员统计
    Map apiStatisticsByStoreUser(Long storeUserId, String queryTime, Integer quertType, Integer orderType);

    //查询店员统计，详细列表
    IPage<TOrder> apiStatisticsListByStoreUser(Long storeUserId, Integer pageNum, Integer pageSize, String queryTime, Integer quertType, Integer orderType);
}